package csc.fresher.service;

import java.sql.Timestamp;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import csc.fresher.dao.DepositAccountTransactionDao;
import csc.fresher.entity.CustomerAccount;
import csc.fresher.entity.DepositTransaction;
import csc.fresher.entity.TransactionState;

@Service
public class DepositAccountTransactionServiceImpl implements
		DepositAccountTransactionService {

	@Autowired
	DepositAccountTransactionDao depositAccountTransactionDao;

	@Override
	public long withdrawFunds(DepositTransaction transaction) {
		return depositAccountTransactionDao
				.createTransactionForWithdrawFunds(transaction);
	}

	@Override
	public long addFunds(DepositTransaction transaction) {
		return depositAccountTransactionDao
				.createTransactionForAddFunds(transaction);
	}

	@Override
	public long transferFunds(DepositTransaction transaction) {
		return depositAccountTransactionDao.createTransactionForTransferFunds(transaction);
	}

	@Override
	public boolean approveWithdrawFunds(DepositTransaction transaction,
			long adminID) {
		return depositAccountTransactionDao.approveTransctionForWithdrawFunds(
				transaction, adminID);
	}

	@Override
	public boolean denyWithdrawFunds(DepositTransaction transaction,
			CustomerAccount account, long adminID) {
		return depositAccountTransactionDao.denyTransactionForWithdrawFunds(
				transaction, account, adminID);
	}

	@Override
	public boolean approveAddFunds(DepositTransaction transaction,
			CustomerAccount account, long adminID) {
		return depositAccountTransactionDao.approveTransctionForAddFunds(
				transaction, account, adminID);
	}

	@Override
	public boolean denyAddFunds(DepositTransaction transaction, long adminID) {
		return depositAccountTransactionDao.denyTransactionForAddFunds(
				transaction, adminID);
	}

	@Override
	public List<DepositTransaction> searchTransactionByCustomerCardIDInGivenPeriod(
			long customerCardID, Timestamp beginDate, Timestamp endDate) {
		return depositAccountTransactionDao
				.searchTransactionByCustomerCardIDInGivenPeriod(customerCardID,
						beginDate, endDate);
	}

	@Override
	public boolean approveTransferFunds(DepositTransaction transaction, CustomerAccount receiver,
			long adminID) {
		return depositAccountTransactionDao.approveTransactionForTransferFunds(
				transaction, receiver, adminID);
	}

	@Override
	public boolean denyTransferFunds(DepositTransaction transaction, CustomerAccount sender,
			long adminID) {
		return depositAccountTransactionDao.denyTransctionForTransferFunds(
				transaction, sender, adminID);
	}

	@Override
	public List<DepositTransaction> getDepositTransactionByState(
			TransactionState transactionState) {
		return depositAccountTransactionDao
				.getDepositTransactionByState(transactionState);
	}

	@Override
	public DepositTransaction getTransactionByID(long transactionID) {
		return depositAccountTransactionDao.getTransactionByID(transactionID);
	}

}
